home *** CD-ROM | disk | FTP | other *** search
/ Software Vault: The Gold Collection / Software Vault - The Gold Collection (American Databankers) (1993).ISO / cdr26 / netprog.zip / NETPROG.TAR / record.s5 / main1.c < prev    next >
C/C++ Source or Header  |  1989-12-17  |  541b  |  30 lines

  1. /*
  2.  * Recording process, first try: use stream pipes.
  3.  */
  4.  
  5. main(argc, argv, envp)
  6. int    argc;
  7. char    **argv;
  8. char    **envp;
  9. {
  10.     int    fd[2], childpid;
  11.  
  12.     if (!isatty(0) || !isatty(1))
  13.         err_quit("stdin and stdout must be a terminal");
  14.  
  15.     if (s_pipe(fd) < 0)
  16.         err_sys("can't create stream pipe");
  17.  
  18.     if ( (childpid = fork()) < 0)
  19.         err_sys("can't fork");
  20.     else if (childpid == 0) {    /* child process */
  21.         close(fd[0]);
  22.         exec_shell(fd[1], argv, envp);
  23.             /* NOTREACHED */
  24.     }
  25.  
  26.     close(fd[1]);            /* parent process */
  27.     pass_all(fd[0], childpid);
  28.     exit(0);
  29. }
  30.